package com.ruoyi.xh.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TablePageDataInfo;
import com.ruoyi.common.core.domain.CommentResult;
import com.ruoyi.xh.domain.XhSet;
import com.ruoyi.xh.service.IXhSetService;

/**
 * 分成设置Controller
 *
 * @author songjw
 * @date 2024-12-13
 */
@Api(tags = "分成设置Controller",value = "分成设置Controller")
@RestController
@RequestMapping("/xh/set")
public class XhSetController extends BaseController {

    @Autowired
    private IXhSetService xhSetService;

    /**
     * 查询分成设置列表
     */
    @PreAuthorize("@ss.hasPermi('xh:set:list')")
    @GetMapping("/list")
    @ApiOperation("查询分成设置列表")
    public TablePageDataInfo<XhSet> list(XhSet xhSet) {
        return TablePageDataInfo.success(xhSetService.selectXhSetList(xhSet));
    }

    /**
     * 获取分成设置详细信息
     */
    @PreAuthorize("@ss.hasPermi('xh:set:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取分成设置详细信息")
    public CommentResult<XhSet> getInfo(@PathVariable("id") Long id) {
        return CommentResult.success(xhSetService.selectXhSetById(id));
    }

    /**
     * 新增分成设置
     */
    @PreAuthorize("@ss.hasPermi('xh:set:add')")
    @Log(title = "分成设置", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增分成设置")
    public CommentResult<XhSet> add(@RequestBody XhSet xhSet) {
            xhSetService.insertXhSet(xhSet);
        return CommentResult.success();
    }

    /**
     * 修改分成设置
     */
    @PreAuthorize("@ss.hasPermi('xh:set:edit')")
    @Log(title = "分成设置", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改分成设置")
    public CommentResult<XhSet> edit(@RequestBody XhSet xhSet) {
            xhSetService.updateXhSet(xhSet);
        return CommentResult.success();
    }

    /**
     * 删除分成设置
     */
    @PreAuthorize("@ss.hasPermi('xh:set:remove')")
    @Log(title = "分成设置", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除分成设置")
    public CommentResult<XhSet> remove(@PathVariable Long[] ids) {
            xhSetService.deleteXhSetByIds(ids);
        return CommentResult.success();
    }
}
